/**
 * Copyright (c) 2014 zhenrongbao.com, Inc. All Rights Reserved
 * @author: jiangshuguang
 * @Date  : 14-11-9
 * @Time  : 下午5:33
 * @brief :
 */
(function () {
    var img = __uri('./image/share.jpg'),
        ShareTip = require("wap_common:widget/ui/sharetip/sharetip.js").ShareTip,
        $page = $('.activity-giftindex'),
        $giftContainer = $page.find('.gift-container');

    P.shareTip = new ShareTip();

    $page.find('.default .gift,.waiting .waiting-pager').click(function(){
        P.shareTip.showShare('' +
            '<div style="font-weight: bold;color:#ff0">分享成功后，就可以拆开红包</div>' +
            '<div style="margin-top:30px;text-align: left;padding:0 10px;">' +
            '红包中有3元、5元、6元、8元、10元、99元，共计六种面额' +
            '</div>' +
            '');
    });

    $giftContainer.find('.btn-share').click(function(){
        P.shareTip.showShare('' +
            '<div style="font-weight: bold;color:#ff0">分享成功后，就可以拆开红包</div>' +
            '<div style="margin-top:30px;text-align: left;padding:0 10px;">' +
            '红包中有3元、5元、6元、8元、10元、99元，共计六种面额' +
            '</div>' +
            '');
    });


    $page.find('.open .gift-content').click(function(){
        location.href= "/wap/wallet";
    });

    $page.find('.waiting .gift-content').click(function(){
        location.reload();
    });

    //分享提高额度
    P.share.data({
        onSendFriends:function(res){
            if(res.err_msg == "share_timeline:ok"){
                $.get("/activity/dogiftshare",function(ret,status){
                    location.reload();
                });
            }
        }
    });

    P.share.data({
        'imgUrl':'https://'+location.host+'/'+img,
        'isAutoGetData':false,
        'lineLink':'https://'+location.host+'/activity/giftindex?else_activity_key='+(P.data('activity_key')),
        'shareTitle':'我在真融宝领红包，人人有份，100%中，分享给你！',
        'descContent':'真融宝像余额宝一样便捷，但拥有15%的更高收益'
    });

    //不使用默认的配置
    P.share.on('beforeGetData',function(){
        P.share.data({
            'isAutoGetData':false
        });
    });
})();